﻿using System;
using NUnit.Framework;

namespace ExtensionMethodExtravaganza.Tests
{
	[TestFixture]
	public class EnumExtensionsTests
	{
		[Flags]
		private enum Numbers
		{
			Zero = 0,
			One = 1,
			Two = 2,
			Four = 4
		}

		[Test]
		public void ContainsFlagValue_String()
		{
			var numbers = Numbers.One | Numbers.Two;

			Assert.IsFalse(numbers.ContainsFlagValue("Four"));
			Assert.IsFalse(numbers.ContainsFlagValue("Invalid"));
			Assert.IsTrue(numbers.ContainsFlagValue("One"));
		}

		[Test]
		public void ContainsFlagValue_Enum()
		{
			var numbers = Numbers.One | Numbers.Two;

			Assert.IsFalse(numbers.ContainsFlagValue(Numbers.Four));
			Assert.IsFalse(numbers.ContainsFlagValue((Numbers)100));
			Assert.IsTrue(numbers.ContainsFlagValue(Numbers.One));
		}
	}
}
